#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace KLib.Scene
{
    public class SceneNode<T> : SceneNode
    {
        #region Fields
        new private T obj;

        #endregion

        #region Properties
        public T Object
        {
            get { return obj; }
        }
        #endregion

        #region Initialization

        public SceneNode(T obj)
        {
            this.obj = obj;
        }

        public SceneNode(T obj, SceneLayer layer)
        {
            this.Layer = layer;
            layer.AddNode(this);
        }
        #endregion

        #region Methods
        public override void Update(GameTime gameTime)
        {
            if (obj is IDestroyable)
                if (((IDestroyable)obj).Destroyed)
                    Layer.nodesToBeRemoved.Add(this);

            IUpdateable updateable = obj as IUpdateable;
            if (updateable != null)
                updateable.Update(gameTime);

            base.Update(gameTime);
        }

        public override void Draw(KLib.Graphics.SpriteRenderer spriteBatch)
        {
            IDrawable drawable = obj as IDrawable;
            if (drawable != null)
                drawable.Draw(spriteBatch);
            if (obj is Entities.Entity)
                (obj as Entities.Entity).Update(new GameTime());
            base.Draw(spriteBatch);
        }

        public override object GetObject()
        {
            return obj;
        }
        #endregion

        #region Helper Methods

        #endregion
    }
}
